import Decimal from "decimal.js";

/**
 * @description: 求和
 * @return {*}
 */
export const addTogether = (num1: number | string, num2: number | string) => new Decimal(num1 || 0).add(num2 || 0).toNumber();

/**
 * @description: 减法
 * @return {*}
 */
export const numSubtract = (num1: number | string, num2: number | string) => new Decimal(num1 || 0).minus(num2 || 0).toNumber();

/**
 * 计算相差百分比
 * @param value1
 * @param value2
 * @returns
 */

export const calculateProfit = (value1, value2) => {
  return Math.round(((value2 - value1) / value1) * 10000) / 100;
};
